home *** CD-ROM | disk | FTP | other *** search
- // the implementation of class PIN_LIST
- // Copyright (C) 1996, 1997 Kazutaka Hirata <khirata@jove.acs.unt.edu>
-
- #include <algorithm>
- #include <string.h>
- #include "../kbandef.h"
- #include "file.h"
-
- #include "pinlist.h"
-
- XY PIN_LIST::get_max() const
- {
- XY ac_max(X_MIN, Y_MIN);
- iterator i;
- TRAVERSE(*this, i) {
- ac_max = ::get_max(ac_max, i->get_max());
- }
- return ac_max;
- }
-
- XY PIN_LIST::get_min() const
- {
- XY ac_min(X_MAX, Y_MAX);
- iterator i;
- TRAVERSE(*this, i) {
- ac_min = ::get_min(ac_min, i->get_min());
- }
- return ac_min;
- }
-
- void PIN_LIST::shift(const XY& ac_dif, PIN_LIST& target) const
- {
- iterator i;
- TRAVERSE(*this, i) {
- target.push_back(i->shift(ac_dif));
- }
- }
-
- int PIN_LIST::save(FILE_NEW& fp) const
- {
- FILE_VERSION fver;
- fp.printf("%s\n", fver.get_version_str(FILE_VERSION::VERSION_200B0));
-
- iterator i;
- TRAVERSE(*this, i) {
- i->save_200b0(fp);
- }
-
- fp.puts("end\n");
- return true;
- }
-
- uint PIN_LIST::load_get_version(FILE_NEW& fp) const
- {
- FILE_VERSION fver;
- char str[1024];
- fp.gets_wo_return(str, 1024);
- return fver.get_version_no(str);
- }
-
- PIN_LIST::LOAD_FUNC_INFO PIN_LIST::load_func_table[] = {
- {FILE_VERSION::VERSION_200A8 , &PIN_ELEMENT::load_200a8},
- {FILE_VERSION::VERSION_200B0 , &PIN_ELEMENT::load_200b0},
- {FILE_VERSION::VERSION_UNKNOWN, NULL }
- };
-
- PIN_LIST::LOAD_FUNC PIN_LIST::get_load_func(uint version) const
- {
- uint sentinel = FILE_VERSION::VERSION_UNKNOWN;
- uint index = search_info_table(load_func_table, sentinel, version);
- return load_func_table[index].func;
- }
-
- int PIN_LIST::load_primitive_170(FILE_NEW& fp)
- {
- for(;;) {
- PIN_ELEMENT element;
- char str[1024];
- fp.gets_wo_return(str, 1024);
- if(!strcmp(str, "end")) {
- break;
- }
- element.load_primitive_170(str);
- push_back(element);
- }
- return true;
- }
-
- int PIN_LIST::load_component_170(FILE_NEW& fp)
- {
- for(;;) {
- PIN_ELEMENT element;
- char str[1024];
- fp.gets_wo_return(str, 1024);
- if(!strcmp(str, "end")) {
- break;
- }
- element.load_component_170(str);
- push_back(element);
- }
- return true;
- }
-
- int PIN_LIST::load(FILE_NEW& fp)
- {
- int retval;
- uint version = load_get_version(fp);
- LOAD_FUNC load_func = get_load_func(version);
- if(load_func != NULL) {
- clear();
- for(;;) {
- PIN_ELEMENT element;
- char str[1024];
- fp.gets_wo_return(str, 1024);
- if(!strcmp(str, "end")) {
- break;
- }
- (element.*load_func)(str);
- push_back(element);
- }
- retval = true;
- } else {
- retval = false;
- }
- return retval;
- }
-
- void PIN_LIST::unselect()
- {
- iterator i;
- TRAVERSE(*this, i) {
- i->unselect();
- }
- }
-
- void PIN_LIST::select_items_in_block(const XY& ac1, const XY& ac2)
- {
- iterator i;
- TRAVERSE(*this, i) {
- if(i->is_in_block(ac1, ac2)) {
- i->select();
- }
- }
- }
-
- void PIN_LIST::collect_selected_items(PIN_LIST& dst) const
- {
- iterator i;
- TRAVERSE(*this, i) {
- if(i->is_selected()) {
- dst.push_back(*i);
- }
- }
- }
-
- void PIN_LIST::remove_selected_items()
- {
- iterator i;
- TRAVERSE(*this, i) {
- if(i->is_selected()) {
- iterator current_i = i--;
- erase(current_i);
- }
- }
- }
-
- void PIN_LIST::collect_aperture(APT_TABLE& apt_table) const
- {
- iterator i;
- TRAVERSE(*this, i) {
- const APERTURE& apt = i->apt();
- if(!apt_table.is_included(apt)) {
- apt_table.push_back(apt);
- }
- }
- }
-
- PIN_ELEMENT* PIN_LIST::search(const XY& ac)
- {
- PIN_ELEMENT* p = NULL;
- iterator i;
- TRAVERSE(*this, i) {
- if(i->is_inside(ac)) {
- p = &*i;
- break;
- }
- }
- return p;
- }
-
- void PIN_LIST::rotate_90()
- {
- iterator i;
- TRAVERSE(*this, i) {
- i->rotate_90();
- }
- }
-
- void PIN_LIST::limit_drill_size(uint drill)
- {
- iterator i;
- TRAVERSE(*this, i) {
- i->limit_drill_size(drill);
- }
- }
-